﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Ana_Form
{
    public partial class Form_MalzemeGirdisi : Form
    {
        DepodataDataContext db;
        MalzemeCinsi Cins;
        Marka marka;
        Model model;
        Malzeme malzeme;
        Malzeme parent;
        Depo depo;
        public Malzeme Malzeme
        {
            get { return malzeme; }
            set { malzeme = value; }
        }
        public Form_MalzemeGirdisi(ref DepodataDataContext Db)
        {
            InitializeComponent();
            db = Db;
        }

        private void btncinsi_Click(object sender, EventArgs e)
        {
            Form_MalzemeCinsi frm = new Form_MalzemeCinsi(ref db);
            if (frm.ShowDialog()==DialogResult.OK)
            {
                Cins = frm.Cinsi;
                lblcinsi.Text = Cins.Adi;
            }
        }


        private void btnmarka_Click_1(object sender, EventArgs e)
        {
            model = null;
            lblmodel.Text = "";
            Form_Marka frm = new Form_Marka(ref db);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                marka = frm.Marka;
                lblmarka.Text = marka.Adi;
            }

        }

        private void lblmarka_TextChanged(object sender, EventArgs e)
        {
            if (lblmarka.Text!="")
            {
                btnmodel.Enabled = true;
            }
            else
            {
                btnmodel.Enabled = false;
            }
        }

        private void btnmodel_Click(object sender, EventArgs e)
        {
            Form_Model frm = new Form_Model(ref db,marka.id);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                model = frm.Mod_el;
                lblmodel.Text = model.Adi+" "+model.Modelno;
            }

        }

        private void lblcinsi_TextChanged(object sender, EventArgs e)
        {
            if (lblcinsi.Text != "")
            {
                btnmarka.Enabled = true;
            }
            else
            {
                btnmarka.Enabled = false;
            }

        }

        private void btnparent_Click(object sender, EventArgs e)
        {
            Form_Malzeme frm = new Form_Malzeme(ref db);
            if (frm.ShowDialog()==DialogResult.OK)
            {
                malzeme = frm.Malzeme;
            }
        }

        private void btndepo_Click(object sender, EventArgs e)
        {
            Form_Depo frm = new Form_Depo(ref db);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                depo = frm.Depos;
            }
        }


    }
}
